package org.lease.service.impl;

import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.lease.mapper.SystemPostMapper;
import org.lease.model.entity.SystemPost;
import org.lease.model.enums.BaseStatus;
import org.lease.service.SystemPostService;
import org.springframework.stereotype.Service;

@Service
public class SystemPostServiceImpl extends ServiceImpl<SystemPostMapper, SystemPost> implements SystemPostService {
    // 分页查询岗位信息
    @Override
    public IPage<SystemPost> page(int current, int size) {
        Page<SystemPost> page = new Page<>(current, size);
        return page(page);
    }

    // 更新岗位状态
    @Override
    public boolean updateStatus(Long id, BaseStatus status) {
        LambdaUpdateWrapper<SystemPost> wrapper = new LambdaUpdateWrapper<>();
        wrapper.set(SystemPost::getStatus, status);
        wrapper.eq(SystemPost::getId, id);
        return update(wrapper);
    }
}
